package io.kblog.service

import io.kblog.dao.BaseDao
import org.springframework.data.domain.Example
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.domain.Specification

interface BaseService<T, ID> {
    var baseDao: BaseDao<T, ID>
    operator fun get(id: ID & Any): T?
    fun getByExample(bean: T & Any): T?
    fun get(spec: Specification<T>): T?
    fun count(): Long
    fun count(bean: T & Any): Long
    fun count(example: Example<T>): Long
    fun count(spec: Specification<T>): Long
    fun findAll(): List<T>
    fun findAll(spec: Specification<T>, pageable: Pageable): Page<T>
    fun findAll(spec: Specification<T>, page: Int, size: Int): Page<T>
    fun findAll(spec: Specification<T>): List<T>
    fun findAll(pageable: Pageable): Page<T>
    fun findAll(page: Int, size: Int): Page<T>
    fun findAllByExample(example: Example<T>, pageable: Pageable): Page<T>
    fun findAllByExample(example: Example<T>, page: Int?, size: Int?): Page<T>
    fun findAllByExample(bean: T & Any, page: Int?, size: Int?): Page<T>
    fun findAllByExample(bean: T & Any, pageable: Pageable): Page<T>
    fun findAllByExample(bean: T & Any): List<T>
    fun findAllById(ids: List<ID>): List<T>
    fun save(bean: T & Any): T
    fun saveAll(beans: List<T>): List<T>
    fun saveByVo(vo: T): T
    fun update(entity: T): T
    fun updateByVo(vo: T): T
    fun deleteAll(entityList: List<T>)
    fun delete(entity: T)
    fun deleteByExample(bean: T)
    fun deleteById(id: ID & Any)
    fun deleteByIdIn(ids: List<ID>)
    fun deleteAllInBatch(entityList: List<T>)
}